// Script example for yALB
//

// Called when the script is loaded.

var counter = 0;

function initialize() {
	m.text = 'Plugin loaded';
	m.informativeText = 'The plugin Dwarfs Validator was loaded';
	m.exec();
	counter = counter + 1;
}

// Called when the script is destroyed
function destroy() {
	m.text = 'Plugin closing.';
	m.informativeText = 'Bye!';
	m.exec();
}

function validateUnit(unitIndex, row) {
	m.text = 'Validating..';
	counter = counter + 1;
    	m.informativeText = 'I\'m currently validating row ' + unitIndex + ' (' + row[0] +'). Counter = ' + counter;
    	m.exec();
	if(unitIndex == 0) {
		m.text = 'Successful';
	    	m.informativeText = 'This is unit 0!';
    		m.exec();
	}
	if(counter == 5) {
		m.text = 'Error';
		m.informativeText = 'Example of error';
		m.exec();
	}
	//errors.append('Error example');
}